package com.gitee.wsl.mathematics.interpolator.ext

import com.gitee.wsl.ext.number.clamp01
import com.gitee.wsl.mathematics.interpolator.PercentOrRatio
import com.gitee.wsl.mathematics.interpolator.Ratio

val PercentOrRatio.clamped: PercentOrRatio get() = Ratio(value.clamp01())

fun PercentOrRatio.clamp(min: PercentOrRatio, max: PercentOrRatio): PercentOrRatio = when {
    this < min -> min
    this > max -> max
    else -> this
}

